﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Adfer
{
    public sealed partial class BitmapViewer : Form
    {
        private BitmapViewer() : this(null)
        {
        }

        public BitmapViewer(Image b)
        {
            if (b == null) throw new ArgumentNullException("b");
            InitializeComponent();
            this.Size = b.Size;
            this.BackgroundImage = b;
        }

        private void BitmapViewer_FormClosing(object sender, FormClosingEventArgs e)
        {
            BeginInvoke(new MethodInvoker(() => this.BackgroundImage.Dispose()));
        }
    }
}